//
//  ReadAnswerTVC.m
//  YHYRealx
//
//  Created by yanghuiyan on 16/4/28.
//  Copyright © 2016年 yanghuiyan. All rights reserved.
//

#import "ReadAnswerTVC.h"

@implementation ReadAnswerTVC

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
//        self.contentView.backgroundColor = [UIColor colorWithRed:247/255.0 green:248/255.0 blue:249/255.0 alpha:1];
        
        self.titleLabel = [YHYBaseLabel new];
        _titleLabel.textColor = [UIColor blueColor];
        self.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.contentView addSubview:self.titleLabel];
        
        self.textView = [YHYBaseTextView new];
        self.textView.delegate = self;
        self.textView.font = [UIFont systemFontOfSize:17];
        self.textView.textColor = [UIColor blackColor];
        self.textView.backgroundColor = [UIColor whiteColor];//设置它的背景颜色
        self.textView.layer.cornerRadius = 5;
        self.textView.layer.masksToBounds = YES;
        self.textView.layer.borderColor = [UIColor lightGrayColor].CGColor;
        self.textView.layer.borderWidth = 2;
        self.textView.scrollEnabled = YES;//是否可以拖动
        self.textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自适应高度
        [self.contentView addSubview:self.textView];
        
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [_titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.contentView).offset(10);
        make.width.equalTo(@(INWIDTH - 20));
        make.height.equalTo(@20);
        
    }];
    
    [_textView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_titleLabel.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView).offset(-10);
//        make.bottom.equalTo(self.contentView).offset(-10);
        make.height.equalTo(@(INHEIGHT * 0.75));
    }];

}

- (void)setQuestionModel:(DetailQuestionDataModel *)questionModel {
    if (_questionModel != questionModel) {
        [_questionModel release];
        _questionModel = [questionModel retain];
    }
    
    _titleLabel.text = questionModel.answer_title;
    NSString *string = [questionModel.answer_content stringByReplacingOccurrencesOfString:@"<br>" withString:@"\n"];
    _textView.text = string;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
